<?php require APP_ROOT.'public/top.php';?>
<div class="admincp-container unfold">
<?php require APP_ROOT.'public/left.php';?>


	<?php
	$type_id = pg('type_id');
	$table_name = M('classify_type')->where(array('type_id' => $type_id))->getField('table_name');
	?>

<div class="right-nav">

<div class="pages">


<div class="flexigrid">
    <div class="mDiv">
      <div class="ftitle">
        <h3>广告列表</h3>
        <h5>(共2条记录)</h5>
      </div>
      <div title="刷新数据" class="pReload"><i class="fa fa-refresh"></i></div>	   
	  <form class="navbar-form form-inline" action="/index.php/admin/Ad/adList" method="post">
      <div class="sDiv">             
        <div class="sDiv2">
         <select name="pid" class="form-control">
              <option value="0">==查看所有==</option>
                                
         </select>
         <input type="text" name="keywords" class="qsbox" placeholder="请输入广告名称">         
         <input type="submit" class="btn" value="搜索">
        </div>
      </div>
     </form>
    </div>
<?php require APP_ROOT.'public/right.php';?>

    <div class="bDiv" style="height: auto;">
      <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
        <table>
        	
            <thead class="tDiv">
            <tr>
              <td class="sign" axis="col0">
                <div style="width: 24px;"><i class="ico-check"></i></div>
              </td>
              <td align="left" class="">
                  <div style="text-align: left; width: 50px;">ID</div>
                </td>
              <?php
					$where = array();
					$where['type_id'] = $type_id;
					$where['list_switch'] = 2;
					$list_input=M('input')->where($where)->order('date asc')->select();
					foreach($list_input as $k=>$v){
					 ?>
              <td align="left" abbr="article_title" axis="col3" class="">
                <div style="text-align: left; width: 100px;" class=""><?php echo $v['input_name']?></div>
              </td>
              <?php }?>
              <td align="center" abbr="article_time" axis="col6" class="">
                <div style="text-align: center; width: 100px;" class="">排序</div>
              </td>
              <td align="center" axis="col1" class="handle">
                <div style="text-align: center; width: 100px;">操作</div>
              </td>
              <td style="width:100%" axis="col7">
                <div></div>
              </td>
            </tr>
          </thead>
          
          <tbody>

				<?php
				$perpage=20;
				$offset=($p-1)*$perpage;//偏移量
				$list=M($table_name)->order('date desc')->limit($offset,$perpage)->select();
				$total_num = M($table_name)->count();
				foreach($list as $k=>$v){
				?>

                          <tr>
                <td class="sign">
                  <div style="width: 24px;"><i class="ico-check"></i></div>
                </td>
                <td align="left" class="">
                  <div style="text-align: left; width: 50px;">105</div>
                </td>
                <?php foreach($list_input as $key=>$val){ ?>
                <td align="left" class="">
                 <div style="text-align: center; width: 100px;">
                  <?php if($val['input_type_id']==7){?>
									<a href="<?php echo $v[$val['field_name']];?>" target="_blank"><img src="<?php echo $v[$val['field_name']];?>" width="50" height="15" /></a>
								<?php }else if($val['input_type_id']==6){?>
									<select name="data[<?php echo $val['field_name'];?>][]">
										<option value="0">请选择</option>
										<?php
										$input = M('input')->where(array('input_pid' => $val['input_id']))->order('date asc')->select();
										foreach($input as $k2=>$v2){
										?>
											<option value="<?php echo $v2['input_id'];?>"<?php if($v[$val['field_name']]==$v2['input_value']){?> selected="selected"<?php }?>><?php echo $v2['input_name'];?></option>
										<?php } ?>
									</select>
								<?php }else{
									if($val['price_switch']>5){
										
										?>
									<a href="index.php?m=cms&a=index&type_id=<?php echo $val['price_switch'];?>&table_name=<?php echo $table_name;?>&content_id=<?php echo $v[$table_name.'_id'];?>"><?php echo $v[$val['field_name']];?></a>
									<?php }else{ echo $v[$val['field_name']];?>
								<?php } }?>
                 </div>
                </td>
                <?php }?>
                
                
                
                
              <td align="center">
                <div style="text-align: center; width: 100px;">
                  <input type="text" onkeyup="this.value=this.value.replace(/[^\d]/g,'')" onpaste="this.value=this.value.replace(/[^\d]/g,'')" onblur="changeTableVal('ad','ad_id','105','orderby',this)" size="4" value="0">
                </div>
              </td>
                <td align="center" class="handle">
                  <div style="text-align: center; width: 100px;">                    
                    <a class="btn red" onclick="delfunc(this)" data-url="/index.php/admin/Ad/adHandle" data-id="105"><i class="fa fa-trash-o"></i>删除</a>                                                            
                    <a href="index.php?m=cms&a=edit&type_id=<?php echo $type_id;?>&table_name=<?php echo $table_name;?>&content_id=<?php echo $v[$table_name.'_id'];?>" class="btn blue"><i class="fa fa-pencil-square-o"></i>编辑</a> </div>
                  
                </td>
                <td align="" class="" style="width: 100%;">
                  <div>&nbsp;</div>
                </td>
              </tr>
       <?php } ?>
              
                      </tbody>
        </table>
	 <!--分页位置--> 
    <div class="dataTables_paginate paging_simple_numbers"><ul class="pagination">    </ul></div> </div>        
<script>
function delfunc(obj){
      layer.confirm('确认删除？', {
                btn: ['确定','取消'] //按钮
              }, function(){
                // 确定
                $.ajax({
                  type : 'post',
                  url : $(obj).attr('data-url'),
                  data : {act:'del',del_id:$(obj).attr('data-id')},
                  dataType : 'json',
                  success : function(data){
                    layer.closeAll();
                    if(data.status==1){
                      layer.msg(data.msg, {icon: 1});
                      $(obj).parent().parent().parent('tr').remove();
                    }else{
                      layer.msg(data.msg, {icon: 2,time: 2000});
                    }
                  }
                })
              }, function(index){
                layer.close(index);
              }
      );
    }
</script>
      </div>
    </div>
    </div>
</div>    
</div>
<?php require APP_ROOT.'public/bottom.php';?>
